package com.ly.mp.dal.comm.jdbc;

import java.util.Iterator;
import java.util.Map;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

import com.ly.mp.dal.comm.helper.SecurityHelper;

public class PropertyPlaceholderConfigurerExt extends PropertySourcesPlaceholderConfigurer {
    private static final Logger log = LoggerFactory.getLogger(PropertyPlaceholderConfigurerExt.class);

    protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
            throws BeansException {
        Iterator var3 = props.entrySet().iterator();

        while (true) {
            Map.Entry entry;
            String key;
            do {
                if (!var3.hasNext()) {
                    super.processProperties(beanFactory, props);
                    return;
                }

                entry = (Map.Entry) var3.next();
                key = (String) entry.getKey();
            } while (!key.toLowerCase().contains("jdbc.url") && !key.toLowerCase().contains("jdbc.username")
                    && !key.toLowerCase().contains("jdbc.password"));

            String val = (String) entry.getValue();

            try {
                if (val.length() >= 8) {
                    String origVal = SecurityHelper.DBDecrypt(val);
                    props.setProperty(key, origVal);
                }
            } catch (Exception var8) {
                log.info("数据库连接配置解密, key: " + key + ", value : " + val);
            }
        }
    }
}